package com.cyf.config;

import com.cyf.constant.DataSourceConstant;
import com.mchange.v2.c3p0.ComboPooledDataSource;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;
import java.beans.PropertyVetoException;

/**
 * @author cyf
 * @description
 * @create 2018-09-14 18:20
 **/
@Configuration
public class DbcpDataSourcePoolConfig {

    @Bean(name = DataSourceConstant.DBCP_DATASOUCE)
    @Qualifier
    public DataSource dataSource() throws PropertyVetoException {
        // dbcp 数据库连接池
        ComboPooledDataSource dataSource = new ComboPooledDataSource();
        dataSource.setDriverClass(DataSourceConstant.DRIVER_CLASS_NAME);
        dataSource.setJdbcUrl(DataSourceConstant.JDBC_URL);
        dataSource.setUser(DataSourceConstant.USER_NAME);
        dataSource.setPassword(DataSourceConstant.PASS_WORD);
        return dataSource;
    }



}
